﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.Common;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Caching;

using Husb.Data;
using Husb.DataUtil;

using CentralOffice.Archive.Data;

using CategoryTable = CentralOffice.Archive.Data.CategoryDataSet.CategoryDataTable;
using CategoryRow = CentralOffice.Archive.Data.CategoryDataSet.CategoryRow;

namespace CentralOffice.Archive.DataAccess
{
    public class ArchiveCategoryAdapter : DataAccessAdapter<CategoryDataSet, CategoryTable, CategoryRow>
    {
        public ArchiveCategoryAdapter()
        {
            //this.TableName = "EnterpriseCategory";

            GetAllStoredProc = "Archive.Category_SelectCategoriesAll";
            InsertStoredProc = "Archive.Category_InsertCategory";
            UpdateStoredProc = "Archive.Category_UpdateCategory";
            DeleteStoredProc = "Archive.Category_DeleteCategory";

            GetByIdStoredProc = "Archive.Category_SelectCategory";
            GetRowCountStoredProc = "Archive.Category_SelectCategoriesRowCount";
            GetPagedStoredProc = "Archive.Category_SelectCategoriesPaged";
        }

        protected override void PopulateInsertParameters(Database db, DbCommand cmd)
        {
            db.AddInParameter(cmd, "Id", DbType.Guid, "Id", DataRowVersion.Current);
            db.AddInParameter(cmd, "Name", DbType.String, "Name", DataRowVersion.Current);
            db.AddInParameter(cmd, "QueryNumber", DbType.AnsiString, "QueryNumber", DataRowVersion.Current);
            //db.AddInParameter(cmd, "OrderNumber", DbType.Int32, "OrderNumber", DataRowVersion.Current);
            //db.AddInParameter(cmd, "ParentId", DbType.Guid, "ParentId", DataRowVersion.Current);

            db.AddInParameter(cmd, "IsDeleted", DbType.Boolean, "IsDeleted", DataRowVersion.Current);
            db.AddInParameter(cmd, "IsActive", DbType.Boolean, "IsActive", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedTime", DbType.DateTime, "CreatedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "CreatedBy", DbType.Guid, "CreatedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "ModifiedTime", DbType.DateTime, "ModifiedTime", DataRowVersion.Current);
            db.AddInParameter(cmd, "LastModifiedBy", DbType.Guid, "LastModifiedBy", DataRowVersion.Current);
            db.AddInParameter(cmd, "Version", DbType.Int32, "Version", DataRowVersion.Current);
            db.AddInParameter(cmd, "Description", DbType.String, "Description", DataRowVersion.Current);
        }
    }
}
